//
//  CAISegmentedPageController.h
//  Demo
//
//  Created by simon on 2017/9/6.
//  Copyright © 2017年 simon. All rights reserved.
//
//    NSAssert(self.dataSource.count > 0, @"Must have one childViewCpntroller at least");
//    NSAssert(self.segmentTitles.count == self.dataSource.count, @"The childViewController's count doesn't equal to the count of segmentTitles");

//  注释：包含顶部CAISegmentedControl 分段选择视图，可以滑动；底部是根据SegmentTitles个数增加的n个子控制器，根据segment选择切换子控制器；
//  2018.3.27 待优化：当控制器往左右方向手动滑动的时候，可以考虑segmentedControl的底部指示条也动画跟着动；

#import <UIKit/UIKit.h>
#import "CAISegmentedControl.h"

NS_ASSUME_NONNULL_BEGIN

@protocol CAISegmentedPageControllerDelegate;

@interface CAISegmentedPageController : UIViewController


@property (nonatomic, weak) id<CAISegmentedPageControllerDelegate>delegate;


///选项卡标题
@property (nonatomic, strong) NSArray<NSString *> *segmentTitles;


///包含的子控制器
@property (nonatomic, strong) NSArray<UIViewController *> *viewControllers;


///当前页面索引
@property (nonatomic, assign) NSInteger currentIndex;



/// 外观segmentControl设置

/// segmented的高度,如果不设置默认高度是40；
@property (nonatomic, assign) CGFloat segmentHeight;

/// 最小item之间间距；default 20
@property (nonatomic, assign) CGFloat segmentMinimumItemSpacing;

/// 外边距:Default is UIEdgeInsetsMake(0, 8, 0, 8)
@property (nonatomic, assign) UIEdgeInsets segmentEdgeInset;

/// segment宽度样式,默认CAISegmentedControlSegmentItemWidthStyleDynamic
@property (nonatomic, assign) CAISegmentedControlSegmentItemWidthStyle widthStyle;



/// 标题未选中的颜色
@property (nonatomic, strong) UIColor *segmentTitleColor;

/// 标题选中的颜色
@property (nonatomic, strong) UIColor *segmentSelectedTitleColor;

/// 标题字体大小
@property (nonatomic, strong) UIFont *segmentFont;

/// 标题选中的字体大小
@property (nonatomic, strong) UIFont *segmentSelectedFont;


/// 指示条

/// 选中指示条样式,默认CAISegmentedControlSelectionStyleFullWidthStripe；
@property (nonatomic, assign) CAISegmentedControlSelectionStyle segmentSelectionStyle;

/// 设置选中指示条颜色
@property (nonatomic, strong) UIColor *segmentSelectionIndicatorColor UI_APPEARANCE_SELECTOR;

/// 设置选中指示条高度， Default is 3.0；
@property (nonatomic, readwrite) CGFloat segmentSelectionIndicatorHeight;

/// BottomDivide

/// 是否隐藏segment的底部margin线，默认NO；
@property (nonatomic, assign) BOOL hideSegmentBottomDivideLine;
@property (nonatomic, strong) UIColor *bottomDivideLineColor;

- (void)setSelectedPageIndex:(NSUInteger)index animated:(BOOL)animated;

@end



@protocol CAISegmentedPageControllerDelegate <NSObject>

@optional


/// 设置文本显示外观
/// - Parameters:
///   - segmentedControl: segmentedControl description
///   - cell: cell description
///   - indexPath: indexPath description
- (void)segmentPageControllerWithSegmentControl:(CAISegmentedControl *)segmentedControl willDisplayCell:(CAISegmentCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath;

/// 选中回调
/// - Parameters:
///   - segmentedControl: segmentedControl description
///   - index: index description
- (void)segmentPageControllerWithSegmentControl:(CAISegmentedControl *)segmentedControl didSelectedIndex:(NSInteger)index;

/// 手势滑动切换的回调
/// - Parameters:
///   - index: index description
///   - completed: completed description
- (void)segmentPageControllerWithTransitionToViewControllersIndex:(NSInteger)index transitionCompleted:(BOOL)completed;

@end

NS_ASSUME_NONNULL_END

